#include "ScnsInclude.h"
#include "init.h"
#include "JctoInclude.h"

static pthread_t pthreadIds[3];

static void*debugTest(void*p)
{
    for(int i=0;i<100000;++i)
    {
        uint8 data[128];
        for(uint8 j=0;j<128;++j){data[j]='a'+(i%26);}
        data[sizeof(data)-1]='\n';
        scnsSmctpPutChars(SCNS_SMCTP_CHANNEL_DEBUG,data,sizeof(data),NULL,0XFFFFFFFF);
    }
    return NULL;
}

static void*oscTest(void*p)
{
    scnsSmctpExtOscilloscopeTest(SCNS_SMCTP_CHANNEL_VISUAL_SCOPE,500,0);
    return NULL;
}

volatile uint8 menuRunFlag=1;

static void*menuTest(void*p)
{
    while(menuRunFlag)
    {
        scnsMenuFresh();
    }
    return NULL;
}

int main(void)
{
    init();
    scnsMenuAddTest(9);
    scnsMenuLoadAll();
    menuRunFlag=1;

    {
        uint8 data[(int)1e6];
        int cnt=0;
        for(int i=0;i<sizeof(data);++cnt)
        {
            i+=hxSNPrintf(data+i,sizeof(data)-i,"%5d:abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\n",cnt);
        }
        hxPrintfFL("cnt=%d\n",cnt);
        scnsSmctpPutChars(SCNS_SMCTP_CHANNEL_DEBUG,data,sizeof(data),NULL,0XFFFFFFFF);
    }

    pthread_create(&pthreadIds[1],NULL,debugTest,NULL);
    pthread_create(&pthreadIds[2],NULL,oscTest,NULL);
    pthread_create(&pthreadIds[0],NULL,menuTest,NULL);

    Sleep(60*60*1000);
    menuRunFlag=0;

    pthread_join(pthreadIds[0],NULL);
    pthread_join(pthreadIds[2],NULL);
    pthread_join(pthreadIds[1],NULL);

    stop(0);
    return 0;
}
